#include<algorithm>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
int a[100005];
int dp1[100005];
int dp2[100005];
int stack[100005];
int main(){
    int x;
    int num=0;
    while(cin>>x){
        num++;
        a[num]=x;
    }
    int len1=1,len2=1;
    dp1[1]=dp2[1]=a[1];
    for(int i=2;i<=num;i++){
        if(a[i]<=dp1[len1])dp1[++len1]=a[i];
        else {
            long long k1=upper_bound(dp1+1,dp1+1+len1,a[i],greater<int>())-dp1;
            dp1[k1]=a[i];
        }
        if(a[i]>dp2[len2])dp2[++len2]=a[i];
        else{
            long long k2=lower_bound(dp2+1,dp2+1+len2,a[i])-dp2;
            dp2[k2]=a[i];
        }
    }
    cout<<len1<<endl<<len2;
    return 0;
}